/**
 * Created by HaiQi on 2017-3-13.
 */

var map, ais, layerS, layerS2, popup, as_control, as_control2, editbar, select,layers;
var PATH_RADIUS = 0.00000001;

var fill = new ol.style.Fill({color:"#FF5500"});
var stroke=new ol.style.Stroke({
    color:"#00FF00",
    width:3
});
var style1=new ol.style.Style({
    fill:fill,
    stroke:stroke,
    image:new ol.style.Circle({
         fill:fill,
        stroke:stroke,
        radius:5
    })
});
var fill2 = new ol.style.Fill({color:"#005500"});
var stroke2=new ol.style.Stroke({
    color:"#336699",
    width:3
});
var style2=new ol.style.Style({
    fill:fill2,
    stroke:stroke2,
    image:new ol.style.Circle({
        fill:fill2,
        stroke:stroke2,
        radius:5
    })
});

var vector = new ol.layer.Vector({
     style:style1,
     source:new ol.source.Vector()
});
var vector2=new ol.layer.Vector({
    style:style2,
    source:new ol.layer.Vector()
});
var options ={

};
function showZoom() {
    if (map.getScale() >= 55367980.3125) {
        map.setCenter(map.getCenter(), 2);
    }
    if (map.getZoom() < 11)
    { plonlat = null; }
    createRed(plonlat);
}
function init() {
    findDimensions();
    layer1 = new ol.layer.Tile({
        source:new ol.source.TileWMS({
            url:"http://map.zmsa.com.cn/map/myImage.ashx",
            params: { "styles": "base", "layers": "ENC", "format": "image/png" }
        })
    });
    layer2 = new ol.layer.Tile({
        source:new ol.source.TileWMS({
            url:"http://map.zmsa.com.cn/map/myImage.ashx",
            params:{ "styles": "std", "layers": "ENC", "format": "image/png" }
        })
    });
    layer3 = new ol.layer.Tile({
        source:new ol.source.TileWMS({
            url:"http://map.zmsa.com.cn/map/myImage.ashx",
            params:{ "styles": "all", "layers": "ENC", "format": "image/png" }
        })
    });
    layerT = new ol.layer.Tile({
        source:new ol.source.XYZ({
            //urls:["http://t0.tianditu.com/DataServer?T=vec_c&X={x}&Y={y}&L={z}", "http://t1.tianditu.com/DataServer?T=vec_c&X={x}&Y={y}&L={z}"],
            url:"http://t0.tianditu.com/DataServer?T=vec_c&X={x}&Y={y}&L={z}",
            params:{ isBaseLayer: true, displayInLayerSwitcher: true }
        })
    });
    layerS=new ol.layer.Tile({
        source:new ol.source.TileWMS({
            url:"http://geo.zmsa.com.cn:8081/geoserver/cyx/wms",
            params:{
                LAYERS: 'cyx:ais_ship',
                transparent: "true",
                format: 'image/png'
            }
        })
    });
//[layer1,layer2,layer3,layerT,layerS],
   map=new ol.Map({
       layers:[layerT],
       view:new ol.View({
           center:[118.8204,32.15705],
           zoom:13
       }),
       target:'map'
   });
}
